<style type="text/css">
	pre {
		border : 2px solid #000;
		margin-bottom : 20px; padding : 5px;
		background-color : #ccc;
		float : left;
		clear : left;
	}
</style>
<?php 
	require_once('Classes/DnaDb.php');
	require_once('Classes/GlobalAlignator.php');
	
	$dnaHandle = new DnaDb();
	$g = new GlobalAlignator('', '');
	
/* TIMETRACKING STARTS */
$mtime = microtime();
$mtime = explode(" ", $mtime);
$mtime = $mtime[1] + $mtime[0];
$starttime = $mtime;
/* TIMETRACKING ENDS */
	
	/* TEST PIVOT CANDIDATES */
	$n1 = 272;
	$n2 = 346;
	$n3 = 9;
	$dna[$n1]  = $dnaHandle->getDnaByKey($n1);
	$dna[$n2]  = $dnaHandle->getDnaByKey($n2);
	$dna[$n3]  = $dnaHandle->getDnaByKey($n3);

	$g->run($dna[$n1]['dnaString'], $dna[$n2]['dnaString']);
	echo "$n1 vs $n2 = ".$g->getPathScore().'<br />';
	$g->run($dna[$n1]['dnaString'], $dna[$n3]['dnaString']);
	echo "$n1 vs $n3 = ".$g->getPathScore().'<br />';
	$g->run($dna[$n2]['dnaString'], $dna[$n3]['dnaString']);
	echo "$n2 vs $n3 = ".$g->getPathScore().'<br />';
	
	/* FIND PIVOT CANDIDATES	
	$randomNumber = 272;
	$data = $dnaHandle->getAllDna();
	$string1 = $dnaHandle->getDnaByKey($randomNumber);
	$stringCounter = 0;
	$compares = array();
	for ($i = 0; $i < count($data); $i++) {
		$string2 = $data[$i];
		if ($data[$i]['dnaKey'] != $randomNumber) {
			$g->run($string1['dnaString'], $string2['dnaString']);
			$compares[$g->getPathScore()] = $string2['dnaKey'];
		}
	}
	ksort($compares);
	
	foreach($compares as $k => $v){
		echo $k.': '.$v.'<br/>';
	} */
	
	/* PIVOTS
	100 vs 343 = -14
	100 vs 384 = 63
	12 vs 19 = 62
	
	272 vs 346 = -32
	272 vs 9 = 5
	346 vs 9 = 108
	*/
	
	/* function readFileToArray($path){
		$lines = file($path);
		if (!$lines) return false;
		return $lines;
	} */
	
	/* DEBUG
	$string1='ATCGAC';
	$string2='CATAC';
	
	$gg = new GlobalAlignator($string1, $string2);
	//$gg = new GlobalAlignator($string1, $string2, 5, 0, 7);
	$gg->printPathMatrix();
	
	?><pre><?php
	$strings = $gg->getComparedStrings();
	echo "\n".$strings['string1']."\n";
	echo $strings['compare']."\n";
	echo $strings['string2'];
	?></pre><?php
	 */	
	
	
/* TIMETRACKING RESULTS */
$mtime = microtime();
$mtime = explode(" ", $mtime);
$mtime = $mtime[1] + $mtime[0];
$endtime = $mtime;
$totaltime = ($endtime - $starttime);
echo "execution time: " . $totaltime . " seconds";
/* TIMETRACKING RESULTS ENDS */
?>
